
<template>
    <div class="ChangeTable">
        <Row>
            <Col span="24">
                <Table
                    width="100%"
                    :columns="isSP ? contractTableHeadPartner : contractTableHead"
                    :data="contractTable"
                    :loading="loading"
                    border
                >
                    <template slot-scope="{ row, index }" slot="action">
                        <Button  :disabled="row.receiptStatus != 'creditSuccess'"  type="primary" size="small" @click="createRevoke(row)">创建撤销</Button>
                        <Button  type="primary" size="small" @click="detail(row)">分配明细</Button>
                    </template>

                    <!-- 付款方式 -->
                    <template slot-scope="{ row, index }" slot="sourceType">
                        <span>{{getTitle('receiptSourceType',row.sourceType)}}</span>
                    </template>
                    <!-- 收款银行 -->
                    <template slot-scope="{ row, index }" slot="bankCode">
                        <span>{{getTitle('bankCode',row.bankCode)}}</span>
                    </template>
                    <!-- 状态 -->
                    <template slot-scope="{ row, index }" slot="receiptStatus">
                        <span>{{getTitle('receiptStatus',row.receiptStatus)}}</span>
                    </template>
                    <template slot-scope="{ row, index }" slot="arriveAmt">
                        <span>{{row.arriveAmt==""?"":row.arriveAmt.toFixed(2)}}</span>
                    </template>
                </Table>
            </Col>
            <Col span="24">
                <Row type="flex" justify="end" class="table-page">
                    <Page
                        :current="contractTable.current"
                        :transfer="true"
                        :total="contractTable.total"
                        size="small"
                        show-total
                        show-elevator
                        show-sizer
                    ></Page>
                </Row>
            </Col>
        </Row>
    </div>
</template>
<script>
    import { getTitleFromDataDict } from "_p/basic/assets/contract/js/utils";

    export default {
        props: {
            formValidate: {
                type: Object,
                required: true
            },
            dataDict: {
                type: Object,
                required: true
            },
            contractTable: {
                type: Array,
                required: true
            },
            loading: {
                type: Boolean,
                required: true,
                default: true
            },
            isSP: {
                type: Boolean,
                required: true,
                default: true
            }
        },
        data() {
            return {
                // loading: false,
                pageSizeOpts: [10, 20, 50, 100],
                contractTableHead: [
                    {
                        title: "操作",
                        slot: "action",
                        width: 220,
                        align: "center"
                    },
                    {
                        title: "付款方式",
                        key: "sourceType",
                        slot: "sourceType",
                    },
                    {
                        title: "合同号",
                        key: "contractNo",
                    },
                    {
                        title: "收款日期",
                        key: "succeedTime",
                    },

                    {
                        title: "收款账号",
                        key: "creditAccount",
                    },
                    {
                        title: "收款金额",
                        key: "arriveAmt",
                        slot:"arriveAmt"
                    },

                    {
                        title: "状态",
                        key: "receiptStatus",
                        slot: "receiptStatus",
                    }
                ],
                contractTableHeadPartner: [
                    {
                        title: "操作",
                        slot: "action",
                        width: 180,
                        align: "center"
                    },
                    {
                        title: "付款方式",
                        key: "sourceType",
                        slot: "sourceType",
                    },
                    {
                        title: "合同号",
                        key: "contractNo",
                    },
                    {
                        title: "收款日期",
                        key: "succeedTime",
                    },

                    {
                        title: "收款账号",
                        key: "creditAccount",
                    },
                    {
                        title: "收款金额",
                        key: "arriveAmt",
                        slot: "arriveAmt",
                    },

                    {
                        title: "状态",
                        key: "receiptStatus",
                    }
                ]
            };
        },
        mounted() { },
        methods: {
            init() { },
            // 分配明细
            detail(row) {
                this.$emit("showDetail", row);
            },

            createRevoke(row) {
                this.$emit("createRevoke", row);
            },
            getTitle(type, val) {
                let data = this.dataDict[type + "Dict"] || [];
                return getTitleFromDataDict(data, val);
            }
        }
    };
</script>
<style scoped>
</style>
